package com.tiku.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tiku.common.ResultJson;
import com.tiku.entity.StaticImg;
import com.tiku.service.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/home")
@ApiOperation("首页相关controller")
@CrossOrigin("*")
public class UserHomeController {

    @Autowired
    private UserActiveTypeService userActiveTypeService;

    @Autowired
    private ProductSpecificationsService specificationsService;

    @Autowired
    private ProfessionCategoriesService categoriesService;

    @Autowired
    private StaticImgService staticImgService;

    @GetMapping("/getUserActiveTypes")
    public ResultJson getUserActiveTypes(){
       return userActiveTypeService.getUserActiveTypes();
    }

    @GetMapping("/getPss/{specId}")
    public ResultJson getPss(@PathVariable("specId")String specId){
        return specificationsService.getUserActiveTypeById(specId);
    }

    @PostMapping("/updateActiveTypes")
    public ResultJson updateActiveTypes(@RequestBody List<String> ids){
        return userActiveTypeService.updateActiveTypes(ids);
    }

    @PostMapping("/activeType")
    public ResultJson activeType(@RequestBody String id){

        return userActiveTypeService.activeType(id);
    }


    @PostMapping("/getChooseExam")
    public ResultJson getChooseExam(){

        return categoriesService.getChooseExam();
    }

    @GetMapping("/getcarousel")
    public ResultJson getcarousel(){
        List<StaticImg> list = staticImgService.list(new LambdaQueryWrapper<StaticImg>()
                .eq(StaticImg::getType, "0"));

        return ResultJson.success(list);
    }

}
